package com.yt.db.config;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfiguration {

    @Bean("dataSourceWrite")
    @ConfigurationProperties(prefix = "spring.datasource.write")
    public DataSource dataSourceWrite() {
        return new HikariDataSource();
    }

    @Bean("dataSourceRead")
    @ConfigurationProperties(prefix = "spring.datasource.read")
    public DataSource dataSourceRead() {
        return new HikariDataSource();
    }

    @Bean("dataSource")
    public DataSource dataSource() {
        return new DynamicDataSource();
    }
}